package second.hash;

import java.util.HashMap;

public class Solution08 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] hash = new int[26];
        for (int i = 0; i < magazine.length(); i++) {
            int index = magazine.charAt(i) - 'a';
            hash[index]++;
        }
        for (int i = 0; i < ransomNote.length(); i++) {
            int index = ransomNote.charAt(i) - 'a';
            if (hash[index] > 0) {
                hash[index]--;
            } else return false;
        }
        return true;
    }
}
